<?php


namespace App\Controller;


use SidToken\Model\InviteUserModel;
use SidToken\Model\SidTransferLogModel;
use SidToken\Model\SidTrxErrModel;
use SidToken\Model\SidUserMinerModel;
use SidToken\Utils\RewardUtil;
use SidToken\Utils\TrxRpc;

class RewardController extends BaseController
{
    public function saveErr()
    {
        $ids = [72, 74, 75, 76, 77, 78];
        $UserMiner = new SidUserMinerModel();
        $TrxErr = new SidTrxErrModel();
        $lists = $UserMiner->where(['id' => array('in', $ids)])->select();
        foreach ($lists as $val) {
            $TrxErr->saveErr("mining", $val, "wallet error");
        }
        $this->jsuccess();
    }
    /**
     * 买10台送1台矿机奖励
     */
    public function rewardBuyMiner()
    {
        $minerId = I("miner_id", 0, 'intval');
        $minerName = I("miner_name", '', 'op_t');
        $minerDayAmount = I("miner_day_amount", 0, 'intval');
        $minerReleaseDay = I("miner_release_day", 0, 'intval');
        $limitAmount = I("limit_amount", 0, 'intval');
        $uid = I("uid", 0, 'intval');
        $UserMinerModel = new SidUserMinerModel();
        $UserMinerModel->rewardMiner($minerId, $minerName, $minerDayAmount, $minerReleaseDay, $limitAmount, $uid);
        $this->jsuccess();
    }

    /**
     * 挖矿奖励 1代 10% 2代5% 3代2%
     *
     */
    public function rewardMining()
    {
        $uid = I("uid", 0, 'intval');
        $amount = I("amount", 0, 'floatval');
        $minerName = I("miner", '', 'op_t');

//        S("cachetest", "hello");
//        echo "cache: ".S("cachetest");
//
//        redis("hello", "caonima");
//        echo "redis: " . redis("hello");

        $RewardUtil = new RewardUtil();
        $res = $RewardUtil->rewardMining($uid, $minerName, $amount);

        $this->jsuccess();

    }
}